# 3、统计当前文件夹的大小（python实现，预备知识：os模块）

import os

def SIZE_DIR(path):
    SIZE=0
    lst=os.listdir(path)
    for i in lst:
        if os.path.isdir(os.path.join(path,i)):
            SIZE+=SIZE_DIR(os.path.join(path,i))
        else:
            SIZE+=os.path.getsize(os.path.join(path,i))
    return SIZE


path=input('请输入文件夹的路径：')
s=SIZE_DIR(path)




def tran(s):
    t=s
    lst=[]
    while t!=0:
        lst.append(t%1024)
        t=t//1024
    return lst
lst=tran(s)
lst2=['B','KB','MB','GB','TB']
result=dict(zip(lst,lst2))
j=len(result)
print(f"{path}文件夹下的大小为:",end=' ')
for i in range(len(result)):
    print(str(str(lst[j-1])+'-'+result[lst[j-1]]),end=' ')
    j-=1